Skip to content

Conversation

@BD103
Copy link
Member

@BD103 BD103 commented Mar 24, 2025

Turns out our #![warn(rustc::internal)] wasn't doing anything, since -Z unstable-options wasn't being passed to the compiler. This PR enables the internal rustc lints in CI, and leaves a comment so people know how to enable it themselves.

With the lint group now enabled, this PR also fixes any leftover warnings. The biggest note right now is that we iterate over a hash map in some places, even though that iteration is not deterministic. There was one spot that I temporarily #[allow(...)]d, even though it wasn't deterministic, since it seemed to complicated to fix right now.

@BD103 BD103 added A-Build-System Related to CI and GitHub Actions A-Linter Related to the linter and custom lints C-Code-Quality An improvement of readability or quality D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review The PR needs to be reviewed before it can be merged labels Mar 24, 2025
@DaAlbrecht
Copy link
Collaborator

DaAlbrecht commented Mar 26, 2025

@BD103 Are you sure we want to enable rustc lints? Asking because of this conversation rust-lang/rust#138586 (comment)

@BD103
Copy link
Member Author

BD103 commented Mar 27, 2025

@BD103 Are you sure we want to enable rustc lints? Asking because of this conversation rust-lang/rust#138586 (comment)

Actually, no, I didn't see that conversation before. I think some lints may still be useful, but maybe it would be good to avoid enabling the entire rustc::internal group.

If you look at the list of lints, which ones do you think are most useful for us?

@BD103 BD103 added S-Needs-Investigation This issue requires detective work to figure out what's going wrong and removed S-Needs-Review The PR needs to be reviewed before it can be merged labels Mar 27, 2025
@DaAlbrecht
Copy link
Collaborator

If you look at the list of lints, which ones do you think are most useful for us?

Hmm, good question. I'm fine with just enabling all and seeing how it feels? Otherwise, these sound most useful to me:

@BD103
Copy link
Member Author

BD103 commented Mar 28, 2025

I'm fine with just enabling all and seeing how it feels?

I think I'm fine with this as well. We'll experiment with them all on (except usage_of_ty_tykind, which is already disabled) and turn them off if they becomes a hassle. If there are really annoying bugs, we can make our own versions (#325) or fix them upstream.

(Also that link on incremental compilation was really cool!)

@BD103 BD103 added S-Needs-Review The PR needs to be reviewed before it can be merged and removed S-Needs-Investigation This issue requires detective work to figure out what's going wrong labels Mar 28, 2025

#[allow(
rustc::potential_query_instability,
reason = "Iterating a hash map may lead to query instability, but the fix is not trivial."
Copy link
Collaborator

@DaAlbrecht DaAlbrecht Mar 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we swap to a BTreeMap?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! I didn't even think of that! I switched it over to BTreeMap. Looks like rustc_data_structures has SortedMap<K, V>, which may be better, but I'll stick to BTreeMap for now.

Copy link
Collaborator

@DaAlbrecht DaAlbrecht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What an interesting issue this has been! Learned a lot :)

@DaAlbrecht DaAlbrecht enabled auto-merge (squash) March 30, 2025 16:09
@DaAlbrecht DaAlbrecht merged commit cbf54fb into main Mar 30, 2025
10 checks passed
@DaAlbrecht DaAlbrecht deleted the enable-rustc-lints branch March 30, 2025 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Build-System Related to CI and GitHub Actions A-Linter Related to the linter and custom lints C-Code-Quality An improvement of readability or quality D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review The PR needs to be reviewed before it can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants